package com.shop.common.enums.pay;

import lombok.Getter;

/**
 * 支付方式  weixin 微信 alipay 支付宝 yue 余额 coin TG
 */
@Getter
public enum PayTypeEnum {


    WEIXIN_JT(3, "weixin", "微信", "TX"),        // 微信-官方
    ALIPAY_JT(2, "alipay", "支付宝", "ALI"),      // 支付宝-官方
    WEIXIN_SAND(13, "weixin", "微信", "SAND"),     // 微信-杉德支付
    ALIPAY_SAND(12, "alipay", "支付宝", "SAND"),   // 支付宝-杉德支付
    YUE(8,"yue", "余额", "TGL"),
    COIN(9,"coin", "TG", "TGL"),
    BROKERAGE(10,"brokerage", "佣金", "TGL"),
    WEIXIN(1, "weixin_gf", "微信", "GF"),//微信官方
    DAIFU_WEIXIN(4, "weixin_daifu", "微信代付", "GFDF"),//微信官方代付
    ;

    private int code;
    private String type;
    private String name;
    private String company;

    PayTypeEnum(int code, String type, String name, String company) {
        this.code = code;
        this.type = type;
        this.name = name;
        this.company = company;
    }

    public static PayTypeEnum val(int code) {
        for (PayTypeEnum enumObj : PayTypeEnum.values()) {
            if(enumObj.code == code) {
                return enumObj;
            }
        }
        return null;
    }

    /**
     * 是否现金方式
     * @return
     */
    public boolean isCash() {
        if(this == WEIXIN_JT || this == ALIPAY_JT || this == WEIXIN_SAND || this == ALIPAY_SAND) return true;
        return false;
    }
}
